package liumengbaio.lolzhangyoubao.Activity.Fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jude.rollviewpager.RollPagerView;

import java.util.ArrayList;
import java.util.List;

import liumengbaio.lolzhangyoubao.Activity.Adapter.ViewPagerAdapter;
import liumengbaio.lolzhangyoubao.R;

/**
 * Created by lanouhn on 16/8/23.
 */
public class FragmentInfo extends Fragment{
    private RollPagerView info_rollPager;
    private TabLayout info_tabLayout;
    private List<Fragment> lists;
    private List<String> tabNames;
    private ViewPager info_viewPager;
    private InfoInfo info;
    private InfoMatch match;
    private InfoNews news;
    private InfoPlay play;
    private ViewPagerAdapter adapter;
    private RollPagerView info_rollPagerView;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_info,null);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView(getView());
        initData();
    }

    private void initData() {
        tabNames.add("最新");
        tabNames.add("新闻");
        tabNames.add("赛事");
        tabNames.add("娱乐");
        lists.add(info);
        lists.add(news);
        lists.add(match);
        lists.add(play);
        adapter=new ViewPagerAdapter(getFragmentManager(),tabNames,lists);
        info_viewPager.setAdapter(adapter);
        info_tabLayout.setupWithViewPager(info_viewPager);

    }

    private void initView(View view) {
        info_tabLayout= (TabLayout) view.findViewById(R.id.info_tablayout);
        info_viewPager= (ViewPager) view.findViewById(R.id.info_viewPager);
        info=new InfoInfo();
        match=new InfoMatch();
        news=new InfoNews();
        play=new InfoPlay();
        tabNames=new ArrayList<>();
        lists=new ArrayList<>();
    }
}
